package com.zfei.gfb.request.h5;

import cn.hutool.core.lang.Validator;
import com.zfei.gfb.bean.Status;
import com.zfei.gfb.bean.StatusException;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

/**
 * @author duyujie
 * @date 2021/8/17
 **/

@ApiModel("企业登录请求入参-/h5/villager/auth")
public class AuthCompanyRequest {

    @ApiModelProperty(value = "手机号", required = true)
    private String phone;
    @ApiModelProperty(value = "验证码", required = true)
    private String code;

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void checkParam() {
        if (StringUtils.isAnyBlank(phone, code)) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }

        if (!Validator.isMobile(phone)) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }

        if (code.length() != 4) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }
    }

}
